Skip to content

Stop exporting tools as a public package deps - #90

Merged
imnasnainaec merged 5 commits into
masterfrom
fix-msbuild-dependency-leak
Sep 14, 2026
Merged

imnasnainaec merged 5 commits into
masterfrom
fix-msbuild-dependency-leak

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Microsoft.Build.Tasks.Core (all three packages) and SIL.Core (SIL.BuildTasks) are plain PackageReferences, so they land in each nuspec as public dependencies. MSBuild is supplied by the host, and these packages already ship the assemblies they need under tools/, so the only effect is pushing their transitive graphs onto consumers.

Marking both PrivateAssets="All" drops them from the nuspec. The tools/ payloads are unchanged.

Measured

Restoring a throwaway project against the packed output, isolated package cache:

Package Consumer TFM 3.1.1 3.3.0 this branch
SIL.ReleaseTasks net462 6 10 6
SIL.ReleaseTasks net48 6 24 6
SIL.BuildTasks net472 — 26 6

The net48 growth is System.Text.Json, System.Resources.Extensions and System.Configuration.ConfigurationManager 10.0.8 among others. On the SIL.BuildTasks side, Newtonsoft.Json 11.0.1 (GHSA-5crp-9r3c-p9vr) drops out of the consumer graph, since it arrived via SIL.Core — so this addresses the exposure the 3.3.0 changelog describes without reverting anything. The SIL.Core 17.0.0 upgrade reverted in #88 may be worth revisiting separately; the Mono.Unix restore breakage that forced it came through the same leak.

History

ba0469f9 removed the Microsoft.Build.* references in 2022 as unnecessary; a1c127d1 (#75) reintroduced this one as a package reference, and it first reached a published nuspec in 3.2.0. SIL.Core came in via 3608e3d5, for DateTimeProvider.

Downstream

sillsdev/libpalaso#1543 currently pins SIL.ReleaseTasks to 3.1.1 on net462/net48 as a workaround, with a comment to revisit once a net462-compatible asset ships. Once this is released that pinning can go away. Worth noting the comment's diagnosis there doesn't match what actually resolves — net48 consumes the net472 asset normally, and net462 restores fine via a compile-only ref/netstandard2.0; neither hits a missing-asset failure.

Not included

Markdig.Signed stays a public dependency of all three packages, and Microsoft.Win32.Registry of SIL.BuildTasks' netstandard2.0 target. Both already ship under tools/, so the same argument applies and the dependency set would end up empty — at which point SuppressDependenciesWhenPacking would say it once instead of per-reference. Happy to do either here.

Testing

  • dotnet build SIL.BuildTasks.sln -c Release clean, 0 warnings
  • dotnet test at the master baseline: 39/39 SIL.ReleaseTasks.Tests pass; SIL.BuildTasks.Tests 176 pass / 6 fail, identical on master. Those 6 are pre-existing and unrelated — filed as FileUpdate date insertion produces machine-dependent output (and 6 tests fail) when regional settings override the date separator #91
  • SIL.BuildTasks.Tests needed an explicit SIL.Core 9.0.0 reference: it had been getting it transitively, and without it SIL.TestUtilities 7.0.0's SIL.Core 7.0.0 wins and 24 tests fail with FileLoadException for the 9.0.0 assembly. Pinning it also clears the MSB3277 conflict warning
  • Packed locally and confirmed both dependencies leave the nuspec while the tools/ payloads still ship every DLL

🤖 Generated with Claude Code


This change is Reviewable

MSBuild is supplied by the host, and these packages already ship the
assemblies they need under tools/, so the dependency only pushed MSBuild's
own transitive graph onto consumers. A net48 consumer of SIL.ReleaseTasks
3.3.0 pulled 24 packages against 6 for 3.1.1.

Marking it PrivateAssets="All" drops it from the nuspec and restores the
3.1.1 dependency surface with the tools/ payload unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Test Results

  4 files  ±0   66 suites  ±0   24s ⏱️ -4s
222 tests ±0  222 ✅ ±0  0 💤 ±0  0 ❌ ±0 
444 runs  ±0  442 ✅ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 0c8efe9. ± Comparison against base commit 7059f0d.

♻️ This comment has been updated with latest results.

@tombogle tombogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving, but I do think that doing the same for SIL.Core (either as part of this PR or separately) is the thing to do. Good work thinking through the right fix.

@tombogle reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

Same reasoning as Microsoft.Build.Tasks.Core: SIL.Core.dll already ships
under tools/ next to the task assembly, so the public dependency only
pushed its subtree onto consumers. A net472 consumer of SIL.BuildTasks
3.3.0 pulled 26 packages; with this it pulls 6, and Newtonsoft.Json 11.0.1
(GHSA-5crp-9r3c-p9vr) drops out of the consumer graph entirely.

SIL.BuildTasks.Tests was getting SIL.Core 9.0.0 transitively through the
project reference. Without it, SIL.TestUtilities 7.0.0's older SIL.Core
7.0.0 wins and the tests fail to load SIL.BuildTasks with a
FileLoadException, so pin 9.0.0 explicitly in the test project.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@imnasnainaec

Copy link
Copy Markdown
Contributor Author

Done — SIL.Core is now PrivateAssets="All" as well, in this PR.

It needed one extra change. SIL.BuildTasks.Tests was getting SIL.Core 9.0.0 transitively through the project reference; without it, SIL.TestUtilities 7.0.0's SIL.Core 7.0.0 wins and 24 tests fail with FileLoadException: Could not load file or assembly 'SIL.Core, Version=9.0.0.0'. Pinned 9.0.0 explicitly in the test project, which also clears the MSB3277 conflict warning that appeared with it.

Consumer graph, measured by restoring a net472 project against the packed output with an isolated package cache:

SIL.BuildTasks 3.3.0 this branch
packages 26 6

Newtonsoft.Json 11.0.1 (GHSA-5crp-9r3c-p9vr) drops out of the consumer graph as a result, since it arrived via SIL.Core. It still ships under tools/ for the tasks' own use, so this addresses the exposure the 3.3.0 changelog describes without reverting anything. Worth a look at whether the SIL.Core 17.0.0 upgrade from #88 can now be revisited separately — the Mono.Unix restore breakage that forced that revert was the same leak.

tools/ payload is byte-for-byte the same set of 26 DLLs as 3.3.0.

Tests are back to the master baseline: 39/39 in SIL.ReleaseTasks.Tests, 176 pass / 6 fail in SIL.BuildTasks.Tests. Those 6 are pre-existing and fail identically on master — FileUpdate formats dates with CultureInfo.CurrentCulture, so a machine whose regional settings override the date separator gets 16-Apr-2026 where the tests expect 16/Apr/2026. Filed separately as #91, since the task's default DateFormat means build output isn't reproducible across machines.

Two things I did not touch, since they widen the scope — say the word if you want either here:

  • Markdig.Signed is still a public dependency of all three packages, and Microsoft.Win32.Registry of SIL.BuildTasks' netstandard2.0 target. Both already ship under tools/, so the same argument applies and the dependency set would end up empty.
  • SuppressDependenciesWhenPacking would express "this package exports nothing" once, instead of per-reference PrivateAssets.

@imnasnainaec imnasnainaec changed the title Stop exporting Microsoft.Build.Tasks.Core as a public package dependency Stop exporting Microsoft.Build.Tasks.Core, SIL.Core as a public package deps Sep 14, 2026
@tombogle

Copy link
Copy Markdown
Contributor

Let's not stop halfway!

I agree that SuppressDependenciesWhenPacking is indeed be the cleaner expression of intent than putting PrivateAssets="All" on every reference.

This is a build-task package whose purpose is specifically to carry its own tooling, so let's make the dependency graph empty, accept the need for explicit test dependencies, and verify that those explicit references stay in the test projects. That's a small and healthy price for not exporting an irrelevant—and potentially vulnerable—dependency graph.

@tombogle tombogle changed the title Stop exporting Microsoft.Build.Tasks.Core, SIL.Core as a public package deps Stop exporting tools as a public package deps Sep 14, 2026
…ssets

Each package's only job is to carry its own build-time tooling under
tools/, so SuppressDependenciesWhenPacking expresses "exports nothing"
once per project instead of PrivateAssets="All" on every reference. This
also catches Markdig.Signed and Microsoft.Win32.Registry, which were
still public, with the tools/ payloads unchanged.

NU5128 is suppressed: pack now omits the dependencies group entirely
rather than emitting it empty per-TFM, which nuget's lib/dependency-group
consistency check otherwise flags.

Removing PrivateAssets from SIL.BuildTasks's own PackageReferences
restores transitive flow through the ProjectReference into
SIL.BuildTasks.Tests (SuppressDependenciesWhenPacking only affects the
packed nuspec), so the explicit SIL.Core pin there stays load-bearing;
reworded its comment to say why.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tombogle
tombogle force-pushed the fix-msbuild-dependency-leak branch from 3b5e94f to f3f45d1 Compare September 14, 2026 17:54
@tombogle

Copy link
Copy Markdown
Contributor

SIL.BuildTasks.Tests/SIL.BuildTasks.Tests.csproj line 29 at r3 (raw file):

         SuppressDependenciesWhenPacking in its csproj); pin the version it's built
         against explicitly here rather than relying on transitive flow through the
         ProjectReference. SIL.TestUtilities 7.0.0 otherwise pulls SIL.Core 7.0.0. -->

We probably don't need to document the exact versions in the comment. Could just say; "Referencing an older version of SIL.TestUtilities otherwise pulls an older version of SIL.Core.
Also, there's probably no great reason to hang back on such an outdated version of SIL.TestUtilities either. If we upgraded to the same version of SIL.Core as SIL.BuildTasks uses, we wouldn't need the explicit reference or this comment, and no one would think it was weird. (We could leave a terse comment just in case they ever go out of sync again, but probably even that is unnecessary.

imnasnainaec and others added 2 commits September 14, 2026 15:12
…inst

SIL.TestUtilities is version-locked to SIL.Core (7.0.0 -> 7.0.0,
9.0.0 -> 9.0.0), so holding it at 7.0.0 while SIL.BuildTasks builds
against SIL.Core 9.0.0 left the test project running a cross-major mix
that the explicit SIL.Core reference was suppressing an MSB3277 conflict
warning for. Bumping to 9.0.0 aligns all four SIL packages; SIL.WritingSystems
moves 7.0.0 -> 9.0.0 with it and nothing new enters the graph.

Deliberately not going to the current 17.0.0: that would drag SIL.Core to
17.0.0, which is what #88 reverted over the Mono.Unix restore breakage.

The SIL.Core reference stays, because FileUpdateTests uses SIL.Providers
directly. Its comment is removed: the version claim it made is obsolete
after the bump, and it named SuppressDependenciesWhenPacking as the reason
transitive flow was unavailable, which was never right for a
ProjectReference -- that property only rewrites the packed nuspec.

Tests unchanged at the master baseline: 176 pass / 6 fail in
SIL.BuildTasks.Tests (the pre-existing locale failures in #91), 39/39 in
SIL.ReleaseTasks.Tests, 0 build warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
[Unreleased] compared against v3.2.2, two releases behind the v3.3.0 tag.

The [3.2.2] definition had neither a git tag nor a matching section, so its
compare URL 404s; [3.3.0] had a section but no definition. Replaced the
former with the latter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@imnasnainaec imnasnainaec left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imnasnainaec reviewed 5 files and all commit messages, and resolved 1 discussion.
Reviewable status: 0 of 5 files reviewed, all discussions resolved (waiting on tombogle).

@tombogle tombogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you squash-merge, be sure to weed out the parts of the commit messages that refer to the intermediate states that will disappear when squashed.

@tombogle reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

@imnasnainaec
imnasnainaec merged commit 5bd98bc into master Sep 14, 2026
6 checks passed
@imnasnainaec
imnasnainaec deleted the fix-msbuild-dependency-leak branch September 14, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants